package com.hyt.it.ogt.ks.util;

import org.apache.commons.lang3.StringUtils;

/**
 * 定义一些公共的key，方便使用且使用是同一规则
 * @author 刘恒活
 * @since 2021/1/21 11:35
 */
public class KeyDefineCommon {
    public static final String SEPARATOR_LINE = ":";
    /**
     * 手机移动设备参数
     */
    public static final String CONST_COLLECT_MOBILE_DEVICE_PARAM = "collectMobileDeviceParam";

    public static final String CONST_COLLECT_MOBILE_DEVICE_MUTE_PARAM = "CONST_COLLECT_MOBILE_DEVICE_MUTE_PARAM";
    public static final String CONST_COLLECT_MOBILE_DEVICE_OFFLINE_PARAM = "CONST_COLLECT_MOBILE_DEVICE_OFFLINE_PARAM";
    public static final String CONST_COLLECT_MOBILE_DEVICE_OFFLINE_NOTICE ="CONST_COLLECT_MOBILE_DEVICE_OFFLINE_NOTICE";
    public static final String CONST_COLLECT_MOBILE_DEVICE_MUTE_NOTICE = "CONST_COLLECT_MOBILE_DEVICE_MUTE_NOTICE";
    /**
     * 与考务定义一致
     */
    public static final String APP_DEVICE_PARAM = "APP_DEVICE_PARAM";
    /**
     * 考生试卷信息；非试卷信息
     */
    public static final String CANDIDATE_CACHE_CANDIDATE_PAPER_INFO = "CANDIDATE_CACHE_CANDIDATE_PAPER_INFO";

    /**
     * 试卷信息 修改成必要信息存入缓存
     */
    public static final String PAPER_CACHE_INFO_SIMPLE = "PAPER_CACHE_INFO_SIMPLE";

    /**
     * 试卷信息
     */
    public static final String PAPER_CACHE_INFO = "PAPER_CACHE_INFO";

    public static final String PAPER_ITEM_CACHE_INFO = "PAPER_ITEM_CACHE_INFO";

    public static final String PAPER_TOPIC_CACHE_INFO = "PAPER_TOPIC_CACHE_INFO";

    /**
     * 考生初始化相关数据，为了减轻服务器登录和初始化试卷并发压力，可提前做好
     */
    public final static String CANDIDATE_DATA_INIT = "CANDIDATE_DATA_INIT";

    public final static String UNIFIED_LOGIN = "UNIFIED_LOGIN";

    public final static String REPEAT_SUBMIT_KEY = "REPEAT_SUBMIT_KEY";

    public final static String RAPER_INIT_KEY = "RAPER_INIT_KEY";

    public final static String WX_QR_CODE = "WX_QR_CODE";

    public final static String INIT_CANDIDATE_PROCESS = "INIT_CANDIDATE_PROCESS";

    public final static String INIT_CANDIDATE_PROCESS_COUNT = "INIT_CANDIDATE_PROCESS_COUNT";

    public final static String INIT_CANDIDATE_CLEAR_PROCESS = "INIT_CANDIDATE_CLEAR_PROCESS";

    public final static String INIT_CANDIDATE_CLEAR_PROCESS_COUNT = "INIT_CANDIDATE_CLEAR_PROCESS_COUNT";

    public final static String CANDIDATE_PAPER_INFO = "CANDIDATE_PAPER_INFO";

    public final static String CANDIDATE_PAPER_TOPIC_INFO = "CANDIDATE_PAPER_TOPIC_INFO";
    
    public final static String CANDIDATE_PAPER_LIST = "CANDIDATE_PAPER_LIST";

    public final static String GET_ITEM_NUMBER_BY_TOPIC_ID = "GET_ITEM_NUMBER_BY_TOPIC_ID";

    public final static String CANDIDATE_DATA_INIT_JOB = "CANDIDATE_DATA_INIT_JOB";

    public final static String CANDIDATE_DATA_CLEAR_JOB = "CANDIDATE_DATA_CLEAR_JOB";

    /**
     *考生完成考试，判分移动试题至备份库
     */
    public final static String CANDIDATE_ANSWER_BACKUP = "CANDIDATE_ANSWER_BACKUP";

    /**
     * 考生完成考试，判分移动考生事件表至备份库
     */
    public final static String CANDIDATE_LOG_BACKUP = "CANDIDATE_LOG_BACKUP";

    public final static String WEBSOCKET_KEY = "WEBSOCKET_KEY";

    public final static String WEBSOCKET_ = "WEBSOCKET_";

    public static final String GET_CANDIDATE_NEXT_NEED_ANSWER_NUMBER = "GET_CANDIDATE_NEXT_NEED_ANSWER_NUMBER";

    /**
     * 机构下考试的皮肤key
     */
    public static final String PROJECT_SKIN_KEY = "PROJECT_SKIN_KEY";

    /**
     * 机构下考试的名称key
     */
    public static final String PROJECT_NAME_KEY = "PROJECT_NAME_KEY";

    public static final String PAPER_TRANSLATE_CACHE_INFO = "PAPER_TRANSLATE_CACHE_INFO";

    public static final String PICTURE_ITEM_UPLOAD_KEY = "PICTURE_ITEM_UPLOAD_KEY";

    /**
     * 考试配置信息key
     */
    public static final String EXAM_INFO_CACHE_INFO = "EXAM_INFO_CACHE_INFO";

    public static final String FILE_LIST_ITEM_UPLOAD_KEY = "FILE_LIST_ITEM_UPLOAD_KEY";

    /**
     * 考生登录时redis锁
     */
    public static final String EXAM_KS_DO_LOGIN = "EXAM_KS_DO_LOGIN";


    /**
     * 考生单题限时重置标识
     */
    public static final String CANDIDATE_RESAT_TIME = "CANDIDATE_RESAT_TIME";

    /**
     * 考生登录时redis锁
     */
    public static String getExamKsDoLoginKey(String examId,String admissionNumber){
        return StringUtils.joinWith(SEPARATOR_LINE, EXAM_KS_DO_LOGIN, examId, admissionNumber);
    }

    /**
     * 考试配置信息key
     */
    public static String getExamInfoCacheInfoKey(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, EXAM_INFO_CACHE_INFO, examId);
    }


    public static String getCandidatePaperKey(String examId, String candidateId, Integer paperSort){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_PAPER_INFO, examId, candidateId, paperSort);
    }

    public static String getCandidatePaperTopicKey(String examId, String candidateId, String candidatePaperId) {
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_PAPER_TOPIC_INFO, examId, candidateId, candidatePaperId);
    }

    public static String getCandidatePaperListKey(String examId, String candidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_PAPER_LIST, examId, candidateId);
    }

    /**
     *
     * @param examId
     * @param examCandidateId
     * @return
     */
    public static String getCollectMobileDeviceParamKey(String examId, String examCandidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CONST_COLLECT_MOBILE_DEVICE_PARAM, examId, examCandidateId);
    }

    public static String getMobileDeviceMuteKey(String examId, String examCandidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CONST_COLLECT_MOBILE_DEVICE_MUTE_PARAM, examId, examCandidateId);
    }

    public static String getMobileDeviceOffLineKey(String examId, String examCandidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CONST_COLLECT_MOBILE_DEVICE_OFFLINE_PARAM, examId, examCandidateId);
    }

    public static String getMobileDeviceMuteNoticeKey(String examId, String examCandidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CONST_COLLECT_MOBILE_DEVICE_MUTE_NOTICE, examId, examCandidateId);
    }

    public static String getMobileDeviceOffLineNoticeKey(String examId, String examCandidateId){
        return StringUtils.joinWith(SEPARATOR_LINE, CONST_COLLECT_MOBILE_DEVICE_OFFLINE_NOTICE, examId, examCandidateId);
    }

    /**
     * 获取移动设备参数
     * @param examId
     * @return
     */
    public static String getAppDeviceParamKey(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, SEPARATOR_LINE, examId);
    }

    /**
     * key -> 考生对应的试卷信息
     * @param candidateId
     * @return
     */
    public static String getCandidateCacheCandidatePaperInfo(String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_CACHE_CANDIDATE_PAPER_INFO, candidateId);
    }

    /**
     * key -> 试卷信息
     * @return
     */
    public static String getPaperInfoKey(String paperId,String paperVersion) {
        return StringUtils.joinWith(SEPARATOR_LINE, PAPER_CACHE_INFO, paperId, paperVersion);
    }

    /**
     * key -> 试卷信息 -- 无题干及描述信息
     * @return
     */
    public static String getPaperInfoSImpleKey(String paperId,String paperVersion) {
        return StringUtils.joinWith(SEPARATOR_LINE, PAPER_CACHE_INFO_SIMPLE, paperId, paperVersion);
    }

    /**
     * key -> 试卷信息
     * @return
     */
    public static String getPaperItemKey(String paperId,String paperVersion) {
        return StringUtils.joinWith(SEPARATOR_LINE, PAPER_ITEM_CACHE_INFO, paperId, paperVersion);
    }

    public static String getPaperTopicKey(String paperId,String paperVersion) {
        return StringUtils.joinWith(SEPARATOR_LINE, PAPER_TOPIC_CACHE_INFO, paperId, paperVersion);
    }

    public static String getCandidateInitData(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_DATA_INIT, examId, candidateId);
    }

    public static String getUifiedLoginData(String loginCode, String loginType) {
        return StringUtils.joinWith(SEPARATOR_LINE, UNIFIED_LOGIN, loginCode, loginType);
    }

    public static String getFinishExamRepeatSubmitKey(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, REPEAT_SUBMIT_KEY, examId, candidateId);
    }

    public static String getPaperInitKey(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, RAPER_INIT_KEY, examId, candidateId);
    }

    public static String getWxQrCodeKey(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, WX_QR_CODE, examId, candidateId);
    }

    public static String getInitCandidateProcessKey(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, INIT_CANDIDATE_PROCESS, examId);
    }

    /**
     * 获取考试初始化的key
     * @param examId
     * @return
     */
    public static String getInitCandidateProcessCountKey(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, INIT_CANDIDATE_PROCESS_COUNT, examId);
    }

    /**
     * 清理试卷过程计算用
     * @param examId
     * @return
     */
    public static String getInitCandidateCLearProcess(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, INIT_CANDIDATE_CLEAR_PROCESS, examId);
    }

    /**
     * 清理试卷过程计算用
     * @param examId
     * @return
     */
    public static String getInitCandidateCLearProcessCount(String examId){
        return StringUtils.joinWith(SEPARATOR_LINE, INIT_CANDIDATE_CLEAR_PROCESS_COUNT, examId);
    }

    public static String getItemNumberByTopicIdKey(String paperId, String paperVersion) {
        return StringUtils.joinWith(SEPARATOR_LINE, GET_ITEM_NUMBER_BY_TOPIC_ID, paperId, paperVersion);
    }

    public static String getWebsocketKey(String sessionId) {
        return StringUtils.joinWith(SEPARATOR_LINE, WEBSOCKET_KEY, WEBSOCKET_ + sessionId);
    }

    public static String getCandidateNextNeedAnswerNumber(String examId, String candidateId, String paperId,
                                                          String paperVersion, String topicId) {
        return StringUtils.joinWith(SEPARATOR_LINE, GET_CANDIDATE_NEXT_NEED_ANSWER_NUMBER, examId, candidateId,
                paperId, paperVersion, topicId);
    }

    /**
     * 获取初始化考生试卷的任务id，一条kw发过来的消息为一个id
     * @param jobId
     * @return
     */
    public static String getInitCandidateJobIdKey(String jobId){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_DATA_INIT_JOB,jobId);
    }


    /**
            * 获取清理考生试卷的任务id，一条kw发过来的消息为一个id
     * @param jobId
     * @return
             */
    public static String getClearCandidateJobIdKey(String jobId){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_DATA_CLEAR_JOB,jobId);
    }

    /**
     * 获取考生事件记录表备份锁的key
     * @param date
     * @return
     */
    public static String getCandidateLogBakcupKey(String date){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_LOG_BACKUP,date);
    }

    /**
     * 获取考生答题表备份锁的key
     * @param date
     * @return
     */
    public static String getCandidateAnswerBakcupKey(String date){
        return StringUtils.joinWith(SEPARATOR_LINE, CANDIDATE_ANSWER_BACKUP,date);
    }

    public static String getPaperTranslateKey(String paperId,String paperVersion, String language) {
        return StringUtils.joinWith(SEPARATOR_LINE, PAPER_TRANSLATE_CACHE_INFO, paperId, paperVersion, language);
    }

    /**
     * 机构下考试的皮肤
     * @param projectId
     * @return
     */
    public static String getProjectExamSkinKey(String projectId){
        return StringUtils.joinWith(SEPARATOR_LINE,PROJECT_SKIN_KEY,projectId);
    }

    /**
     * 机构下考试名称
     * @param officeId
     * @return
     */
    public static String getProjectNameKey(String officeId){
        return StringUtils.joinWith(SEPARATOR_LINE,PROJECT_NAME_KEY,officeId);
    }

    public static String getPictureItemUploadKey(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, PICTURE_ITEM_UPLOAD_KEY, examId, candidateId);
    }

    public static String getFileListItemUploadKey(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE, FILE_LIST_ITEM_UPLOAD_KEY, examId, candidateId);
    }


    /**
     * 考生单题限时重置标识
     */
    public static String getCandidateResatTime(String examId, String candidateId) {
        return StringUtils.joinWith(SEPARATOR_LINE,CANDIDATE_RESAT_TIME, examId, candidateId);
    }
}


